package com.liyang.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @BelongsProject: cloud-2024
 * @BelongsPackage: com.liyang.springcloud.config
 * @Author: liyang
 * @CreateTime: 2023-12-29  10:33
 * @Description: 路由配置类  注入
 * @Version: 1.0
 */
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customerRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route("path_route_liyang",
                        r -> r.path("/guoji")
                                .uri("http://news.baidu.com/guonei"))
                .build();
        return routes.build();
    }
}
